import {reactive, onMounted } from "vue";
import axios from "axios";

// https://dog.ceo/api/breed/pembroke/images/random

export default function (){
    let doglist = reactive([
        "https:\/\/images.dog.ceo\/breeds\/pembroke\/n02113023_4269.jpg",
      ]);
      
    async function getdog() {
      try {
        let result = await axios.get(
          "https://dog.ceo/api/breed/pembroke/images/random"
        );
        // console.log(result.data.message);
        doglist.push(result.data.message);
      } catch (error) {
         alert(error);
       }
    }
    //钩子
    onMounted(()=>{
      getdog()
    })
    // 向外部提供
    return {doglist,getdog}
}